<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>原生js实现tab切换</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <!-- html部分 -->
    <div class="tab">
      <div class="tab-h">
        <ul class="tab-h-list">
          <!-- index设置为0开始是为了让它的值作为页面显示div的索引值 -->
          <li index="0" class="tab-h-item active">
            <a href="javascript:void(0)">产品</a>
          </li>
          <li index="1" class="tab-h-item">
            <a href="javascript:void(0)">用户</a>
          </li>
          <li index="2" class="tab-h-item">
            <a href="javascript:void(0)">新闻</a>
          </li>
          <li index="3" class="tab-h-item">
            <a href="javascript:void(0)">体育</a>
          </li>
        </ul>
      </div>
      <div class="tab-b">
        <div index="0" class="tab-b-item active">页面1</div>
        <div index="1" class="tab-b-item">页面2</div>
        <div index="2" class="tab-b-item">页面3</div>
        <div index="3" class="tab-b-item">页面4</div>
      </div>
    </div>
    <script src="index.js"></script>
  </body>
</html>
